package com.jd.sunny.java.multithreading.callablefuture;

import org.apache.log4j.Logger;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Description:FutureTask implements RunnableFuture<V> extends Runnable, Future<V>
 * @author:sunny
 * @since:2012-12-25 15:02
 * @version:1.0.0
 */
public class FutureTaskTest {

   private final static Logger logger = Logger.getLogger(FutureTaskTest.class);

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        //create a callable object
        MyCallable myCallable = new MyCallable("sunlin");

        //create a FutureTask object
        FutureTask futureTask = new FutureTask(myCallable);

        //new a thread and run
        Thread thread = new Thread(futureTask);
        thread.start();

        logger.info("FutureTask result:" +  futureTask.get().toString());
    }

    
}
